#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int get_sum(int nums[], int left, int right)
{
	int r = 0;
	for(int i=left; i<=right; ++i) {
		r += nums[i];
	}
	return r;
}

int binfind(int nums[], int left, int right)
{
	int mid = (right - left)/2;
	if(mid==0) {
		return nums[left-1] > nums[right-1] ? right : left;
	}
	int sum1 = get_sum(nums, left-1, left+mid-1);
	int sum2 = get_sum(nums, left+mid, right-1);
	if( sum1 > sum2 ) {
		return binfind(nums, left+mid, right);
	}
	return binfind(nums, left, left+mid);
}

int main()
{
	const int N=16;
	vector<int> nums;
	for(int i=0; i<N; i++) {
		nums.push_back(1);
	}
	int b;
	while(1) {
		cin >> b;
		if( b >= 0 && b < nums.size()) {
			nums[b] = 0;
			break;
		}
	}
	
	cout << binfind(&nums[0], 1, N);
}
